/*
 * 	<pre>
 *	EasyPeas.
 *  Copyright (C) 2007 S Owen
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Jul 24, 2007
 * Invoker.java
 * </pre>
 */
package org.easypeas.invocation;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.easypeas.exceptions.ForwardNotFoundException;
import org.easypeas.exceptions.ResourceInvocationFailure;
import org.easypeas.exceptions.UnknownResourceException;
import org.easypeas.exceptions.UnresolvedMethodException;
import org.easypeas.mappings.Mappings;

/**
 * In interface defining an Invoker whose responsibility is to work on the
 * HttpServletRequest and path, together with the defined mappings, to determine
 * the EasyPea and invoke the appropriate method on it.<br>
 * 
 * @see Mappings
 * @author S Owen
 * 
 */
public interface Invoker {

	/**
	 * Forwards on GET request to an EasyPea {@link View} or {@link Accessor}.<br>
	 * The provided {@link Mappings} together with the path determines which
	 * EasyPea and method is invoked. <br>
	 * The Map returned is ultimately passed on to a Velocity template for
	 * mapping to elements within a browser view.
	 * 
	 * @param request
	 *            the request
	 * @param response
	 *            the response
	 * @param mappings
	 *            the mapping
	 * @param path
	 *            the path
	 * 
	 * @return Map
	 * 
	 * @throws UnresolvedMethodException
	 *             the unresolved method exception
	 * @throws UnknownResourceException
	 *             the unknown resource exception
	 * @throws ResourceInvocationFailure
	 *             the resource invocation failure
	 * 
	 * @see View
	 * @see Mappings
	 * @see Accessor
	 */
	Map<String, Object> invokePath(HttpServletRequest request,
			HttpServletResponse response, Mappings mappings, String path)
			throws UnresolvedMethodException, UnknownResourceException,
			ResourceInvocationFailure;

	/**
	 * Forwards on a POST request to an EasyPea {@link Action}.<br>
	 * The provided {@link Mappings} together with the path determines which
	 * EasyPea and method is invoked. <br>
	 * The Map returned is ultimately passed on to a Velocity template for
	 * mapping to elements within a browser view.
	 * 
	 * @param request
	 *            the request
	 * @param response
	 *            the response
	 * @param mappings
	 *            the mappings
	 * @param path
	 *            the path
	 * 
	 * @return the map< string, object>
	 * 
	 * @throws UnresolvedMethodException
	 *             the unresolved method exception
	 * @throws UnknownResourceException
	 *             the unknown resource exception
	 * @throws ResourceInvocationFailure
	 *             the resource invocation failure
	 * @throws ForwardNotFoundException
	 *             the forward not found exception
	 *             
	 * @see Action
	 * @see Mappings
	 */
	Map<String, Object> invokeActionPath(HttpServletRequest request,
			HttpServletResponse response, Mappings mappings, String path)
			throws UnresolvedMethodException, UnknownResourceException,
			ResourceInvocationFailure, ForwardNotFoundException;
}
